//获取应用实例
const app = getApp();
// 引入AES.js
var baseJs = require("../../common/base.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name:"",
    phone:"",
    password:"",
    id:"",
    // 
    uid:"",
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(options);
    this.setData({
      uid: wx.getStorageSync('uid'),
      name:options.name,
      phone:options.phone,
      password:options.password,
      id:options.id,
    })
    
  },

  // 
  formSubmit: function (e) {
    var that = this;
    var uid = this.data.uid;
    var id = this.data.id;
    console.log(e);
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=BusinessUpdateSalerInfo&UID=" + uid + "&TrueName=" + e.detail.value.name + "&UserPhone=" + e.detail.value.phone + "&UserPassWord=" + e.detail.value.password + "&SalerId=" + id),
      success: function (res) {
        var json = JSON.parse(baseJs.decryUrl(res.data));
        console.log(json);
        if (json.ResultFlag == 1) {
          wx.showToast({
            title: "修改成功！",
            icon: 'none',
            duration: 2000
          });
          setTimeout(function () {
            wx.navigateTo({
              url: '/packageA/powerGive/powerGive',
            })
          }, 500)

        } else {
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 2000
          });
        }

      }
    })
  },
  formReset: function () {
    wx.navigateTo({
      url: '/packageA/powerGive/powerGive',
    })
  }
  // 
})